﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace gecommon
{
    //包含2个队列 一个用于gateway=>agenet 一个用于agenet=>gateway
    public class Channel
    {
        private static Channel _channel;

        static Channel()
        {
            _channel = new Channel();
        }

        public static Channel Instance()
        {
            return _channel;
        }

        private WaitFreeQueue<object> _gate2agent = new WaitFreeQueue<object>();

        private WaitFreeQueue<object> _agent2gate = new WaitFreeQueue<object>();

        public void Send2Agent(object item)
        {
            _gate2agent.Enqueue(item);
        }

        public object Recv4Agent()
        {
            return _gate2agent.Dequeue();
        }

        public void Send2Gate(object item)
        {
            _agent2gate.Enqueue(item);
        }

        public object Recv4Gate()
        {
            return _agent2gate.Dequeue();
        }
    }
}
